!function($) {
    var methods = {
        init : function(data, options) {
            return this.each(function() {
                var $this = $(this);
                var vis;
                $this.data("mutationviewer.plot", (vis = MutationVisFactory.create($this.get(0))));
                vis.draw(data, options);
            });
        },
        set_stems : function(stems_enabled) {
            return this.each(function() {
                var vis = $(this).data("mutationviewer.plot");
                if (vis) {
                    vis.setStems(stems_enabled);
                }
            });
        },
        set_protein_domains : function(param_subtypes) {
            return this.each(function() {
                var vis = $(this).data("mutationviewer.plot");
                if (vis) {
                    vis.setProteinDomains(param_subtypes);
                }
            });
        },
        set_protein_scales : function(param_subtypes) {
            return this.each(function() {
                var vis = $(this).data("mutationviewer.plot");
                if (vis) {
                    vis.setProteinScales(param_subtypes);
                }
            });
        }
    };

    $.fn.mutationviewplot = function( method ) {
      if ( methods[method] ){
          return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
      }
      else if ( typeof method === 'object' || ! method ) {
          return methods.init.apply( this, arguments );
      }
      else {
          $.error( 'Method ' +  method + ' does not exist on jQuery.mutationviewplot' );
      }
    };
}(window.jQuery);
